package main

import (
	"net/http"
	_ "net/http/pprof"
	"os"
	"runtime/trace"
)

// 通过 pprof 来监测 goroutine 数量
// 随便在哪个路径执行 go tool pprof -http=:1248 http://localhost:6060/debug/pprof/goroutine
// go tool trace trace.out
func main() {
	for i := 0; i < 100; i++ {
		go func() {
			select {}
		}()
	}

	go func() {
		http.ListenAndServe("localhost:6060", nil)
	}()

	// go tool trace trace.out
	f, err := os.Create("trace.out")
	if err != nil {
		panic(err)
	}

	defer f.Close()

	err = trace.Start(f)
	if err != nil {
		panic(err)
	}

	defer trace.Stop()

	select {}
}
